<?php
set_include_path ( $_SERVER ['DOCUMENT_ROOT'] );
include_once 'admin/includes/functions/admin-functions.php';
global $DBobject, $SMARTY, $CONFIG;
if(empty($_SESSION['user']['admin'])){
  header("location: https://www.readysteadygokids.com.au/admin/login");
  die();
}

if(!empty($_POST['hide_news']) && $_POST['hide_news'] == true) $_SESSION['user']['admin']['hide_news'] = true;
if( $_SESSION['user']['admin']["level"] < 3 && (empty($_SESSION['user']['admin']['hide_news']) || $_SESSION['user']['admin']['hide_news'] != true)){
	$admin = ($_SESSION['user']['admin']["level"] == 1)?1:0;
	$franchisee = ($_SESSION['user']['admin']["level"] == 2)?1:0;
	
	$sql = "SELECT * FROM tbl_listing LEFT JOIN tbl_news ON news_listing_id = listing_id 
			WHERE listing_type_id = '7' AND listing_deleted IS NULL AND listing_published = '1' AND news_deleted IS NULL 
				AND news_start_date <= CURDATE() AND (news_end_date >= CURDATE() OR news_end_date IS NULL OR news_end_date = '') AND listing_flag1 = '1' AND  (listing_flag2 = :listing_flag2 OR listing_flag3 = :listing_flag3) ORDER BY news_start_date DESC";
	$res = $DBobject->executeSQL($sql, array(":listing_flag2"=>$admin,":listing_flag3"=>$franchisee));
	$SMARTY->assign("important_news", unclean($res));
}



